package com.running.base.run.api;

import com.running.base.run.jms.sender.JMSSender;
import com.running.base.run.params.base.ResultBody;
import com.running.base.run.util.SpringContextsUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;



@RestController
@RequestMapping("/api/monitor")
public class AliveController {

    private static final Logger logger = LoggerFactory.getLogger(AliveController.class);

    @RequestMapping("/jms")
    public ResultBody jms(HttpServletRequest request) throws Exception {
        logger.info("探活jms开始.");
        try {
            JMSSender jmsSender = (JMSSender) SpringContextsUtil.getBean("JMSSender");
            jmsSender.sendJmsXmlContent("hello world!");
            logger.info("探活jms完成！");
        } catch (Exception e) {
            logger.error("探活jms异常，errMsg={}", e.getMessage());
        }

        return ResultBody.success();
    }

}
